/**
 * Copyright (c) 2011 eelpo.com
 * All rights reserved.
 */
package com.eelpo.cmmp.core.wicket.page.extensions;

import java.util.List;

import com.eelpo.cmmp.core.wicket.page.paging.DynamicPagingWebPage;
import com.eelpo.cmmp.core.wicket.panel.container.SearchListContainer;
import com.eelpo.cmmp.core.wicket.panel.grid.DataGrid;
import com.eelpo.cmmp.core.wicket.panel.grid.column.IColumnHeader;
import com.eelpo.cmmp.core.wicket.panel.paging.ISort;

import org.apache.wicket.markup.html.panel.Panel;

/**
 * <pre>
 * 
 * 搜索列表基类页面
 * 
 * </pre>
 * 
 * @author <a href="mailto:Brian@eelpo.com">汪洪州</a>
 * @since 1.0
 */
public abstract class SerachListWebPage<T extends ISort> extends DynamicPagingWebPage<T> {

	/**
	 * @param parameter
	 */
	public SerachListWebPage(String title, int pageSize, T parameter) {

		super(parameter);

		// 搜索列表面板
		add(renderSearchListContainer("container", title, pageSize));

	}

	public Panel renderSearchListContainer(String id, String title, int pageSize) {
		return new SearchListContainer<T>(id, title, pageSize) {

			/**
			 * serialVersionUID
			 */
			private static final long serialVersionUID = -6721272925143913463L;

			@Override
			public Panel renderSearchPanel(String id) {
				return SerachListWebPage.this.renderSearchPanel(id);
			}

			@Override
			public DataGrid<T> renderDataGrid(String id, int pageSize) {
				return new DataGrid<T>(id, pageSize, renderColumns(), getDataProvider());
			}

		};
	}

	public abstract Panel renderSearchPanel(String id);

	public abstract List<IColumnHeader<T>> renderColumns();
}
